import http from '@/utils/request'

// API基础URL
const API_BASE_URL = 'http://120.46.20.35:3000/api'

// API路径
const API = {
  // 注册
  REGISTER: '/register',
  // 登录
  LOGIN: '/login',
  // 获取sessionId
  SESSION_ID: '/getSessionId',
  // 查询积分
  POINTS: '/getPoints',
  // 发送绑定验证码
  BIND_SMS: '/sendBindCode',
  // 绑定账号
  BIND_ACCOUNT: '/bindAccount',
  // 自动下单
  AUTO_ORDER: '/autoOrder',
  // 自定义下单
  CUSTOM_ORDER: '/customOrder',
  // 下单
  ORDER_PAY: '/orderPay',
  // 重发验证码
  RESEND_SMS: '/resendOrderSms',
  // 获取签名
  GET_SIGN: '/getSign',
  // 获取openId
  GET_OPEN_ID: '/getOpenId',
  // 保存数据
  SAVE_DATA: '/savedata',
  // 阻止电话号码
  BLOCK_PHONE: '/blockphone',
  // 获取图片
  GET_PIC:'/getpic',
  // 添加手机号
  ADD_PHONE: '/addphone',
  // 手机积分添加
  UPDATE_PHONE: '/updatephone',
  // 未下单错误原因
  ERROR_PHONE: '/erphone',
  // 获取银行卡渠道ID
  GET_YHKQ: '/getyhkq',
  // 查询手机归属地
  CHECK_PHONE: '/checkPhone',
  // 查询ip
  GET_IP:'/index/getip',
  //验证是否输入验证码接口
  IFYZ:'/ifyz',
  // 新用户输入验证码并且跳转到第二页时调用接口
  UPTOTWO:'/uptotwo',
  // 添加非移动手机接口
  ADD_OTHER_PHONE:'/addotherphone',
  // 是否点击银行券接口
  CLICK_YH:'/clickyh',
}

// 注册接口
export const register = (data) => http.post(API.REGISTER, data)

// 登录接口
export const login = (data) => http.post(API.LOGIN, data)

// 获取sessionId接口
export const getSessionId = (data) => http.post(API.SESSION_ID, data)

// 查询积分接口
export const getPoints = (data) => http.post(API.POINTS, data)

// 发送绑定验证码接口
export const sendBindCode = (data) => http.post(API.BIND_SMS, data)

// 绑定账号接口
export const bindAccount = (data) => http.post(API.BIND_ACCOUNT, data)

// 自动下单接口
export const autoOrder = (data) => http.post(API.AUTO_ORDER, data)

// 自定义下单接口
export const customOrder = (data) => http.post(API.CUSTOM_ORDER, data)

// 下单接口
export const orderPay = (data) => http.post(API.ORDER_PAY, data)

// 重发验证码接口
export const resendOrderSms = (data) => http.post(API.RESEND_SMS, data)

// 获取签名接口
export const getSign = (data) => http.post(API.GET_SIGN, data)

// 获取用户优惠券列表
export function getUserCoupons(openid, data, config = {}) {
  return http.post(`/v3/marketing/favor/users/${openid}/coupons`, data, {
    ...config,
    header: {
      'Accept': 'application/json',
      'Content-Type': 'application/json',
      ...config.headers
    }
  })
} 
// 获取openId接口
export const getOpenIds = (data) => http.post(API.GET_OPEN_ID, data)

// 保存数据接口
export const saveData = (data) => http.post(API.SAVE_DATA, data)

// 阻止电话号码接口
export const blockPhone = (data) => http.post(API.BLOCK_PHONE, data)
// 获取图片
export const getPic = (data) => http.post(API.GET_PIC, data)
// 添加手机号
export const addPhone = (data) => http.post(API.ADD_PHONE, data)
// 手机积分添加接口
export const updatePhone = (data) => http.post(API.UPDATE_PHONE, data)
// 未下单错误原因
export const errorPhone = (data) => http.post(API.ERROR_PHONE, data)
// 获取银行卡渠道ID
export const getYhkq = (data) => http.get(API.GET_YHKQ, data)
// 查询手机归属地
export const checkPhone = (data) => http.post(API.CHECK_PHONE, data)
// 获取ip
export const getIp = (data) => http.get(API.GET_IP, data)
// 验证是否输入验证码接口
export const ifyz = (data)=> http.post(API.IFYZ,data)
// 新用户输入验证码并且跳转到第二页时调用接口
export const uptotwo = (data)=> http.post(API.UPTOTWO,data)
// 添加非移动手机接口
export const addotherphone = (data)=> http.post(API.ADD_OTHER_PHONE,data)
// 是否点击银行券接口
export const clickyh = (data)=> http.post(API.CLICK_YH,data)